package com.shuang.controller;

import java.util.Date;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.shuang.common.PageObject;
import com.shuang.pojo.DbUser;
import com.shuang.service.DbUserService;

@RequestMapping("/admin")
@Controller
public class AdminHanlder {
	
	@Resource(name="dbUserService")
	private DbUserService dbUserService;
	
	@RequestMapping("/getAdminList")
	@ResponseBody
	public PageObject<DbUser> getAdminList(int page,int rows){
		return dbUserService.getAdminList(page,rows);
	}
	
	
	@RequestMapping("/addAdmin")
	@ResponseBody
	public int addAdmin(DbUser dbUser) throws Exception{
		dbUser.setuRole((short)1);
		dbUser.setuRegisterTime(new Date());
		dbUser.setuStatus((short)1);
		dbUser.setuScore(0l);
		return dbUserService.insertUser(dbUser);
		
	}
	
	@RequestMapping("/updateAdmin")
	@ResponseBody
	public int updateAdmin(DbUser dbUser) throws Exception{
		return dbUserService.updateUser(dbUser);
		
	}
}
